{% extends "base.html" %} {% block html_title %} 玩家详情 {% endblock html_title %} {% block page_title %} 玩家详情 {% endblock page_title %} {% block content %}
<div id="content">
    <el-row>
        <el-card class="box-card">
            <div slot="header" class="clearfix">
                <span>玩家数据统计</span>
            </div>
{#            <el-row :gutter="20">#}
{#                <el-col :xs="12" :sm="6" :md="4">玩家昵称</el-col>#}
{#                <el-col :xs="12" :sm="8" :md="12">{{player.nickname}}</el-col>#}
{#            </el-row>#}
{#            <el-row :gutter="20">#}
{#                <el-col :xs="12" :sm="6" :md="4">玩家微信id</el-col>#}
{#                <el-col :xs="12" :sm="8" :md="12">{{player.wxid}}</el-col>#}
{#            </el-row>#}
{#            <el-row :gutter="20">#}
{#                <el-col :xs="12" :sm="6" :md="4" style="font-weight: bolder;">余分</el-col>#}
{#                <el-col :xs="12" :sm="8" :md="12" style="font-weight: bold; color: #f90000;">{{player.totalPoint}}</el-col>#}
{#            </el-row>#}
{#            <el-row :gutter="20">#}
{#                <el-col :xs="12" :sm="6" :md="4">下注次数</el-col>#}
{#                <el-col :xs="12" :sm="8" :md="12">{{player.wagerCount}}</el-col>#}
{#                <el-col :xs="12" :sm="6" :md="4">下注积分</el-col>#}
{#                <el-col :xs="12" :sm="8" :md="12">{{player.wagerAmount}}</el-col>#}
{#                <el-col :xs="12" :sm="6" :md="4">盈亏</el-col>#}
{#                <el-col :xs="12" :sm="8" :md="12">{{player.earnedAmount}}</el-col>#}
{#            </el-row>#}
            <el-row :gutter="20">
                <el-col :xs="12" :sm="6" :md="4">玩家昵称</el-col>
                <el-col :xs="12" :sm="6" :md="4">{{player.nickname}}</el-col>
                <el-col :xs="12" :sm="6" :md="4">微信号</el-col>
                <el-col :xs="12" :sm="6" :md="4">{{player.wxid}}</el-col>
            </el-row>
            <el-row :gutter="20">
                <el-col :xs="12" :sm="6" :md="4">上分记录</el-col>
                <el-col :xs="12" :sm="6" :md="4">{{player.upPoint}}</el-col>
                <el-col :xs="12" :sm="6" :md="4">下分记录</el-col>
                <el-col :xs="12" :sm="6" :md="4">{{player.downPoint}}</el-col>

            </el-row>
            <el-row :gutter="20" style="line-height: 36px;">
                <el-col :xs="12" :sm="6" :md="4">盈亏</el-col>
                <el-col :xs="12" :sm="6" :md="4">{{player.earnedAmount}}</el-col>
                <el-col :xs="12" :sm="6" :md="4" style="line-height: 36px; font-weight: bolder;">余分</el-col>
                <el-col :xs="12" :sm="6" :md="4" style="font-size:24px; color: #f90000;">{{player.totalPoint}}</el-col>
            </el-row>
        </el-card>
    </el-row>
    {% if current_user.is_admin %}
    <el-row>
        <el-card class="box-card">
            <div slot="header" class="clearfix">
                <span>上下分</span>
            </div>
            <el-row :gutter="5">
                <el-col :xs="8" :sm="4" :lg="3">
                    <el-input v-model="upPoint" autofocus="true" style="font-size: 18px;"></el-input>
                </el-col>
                <el-col :xs="12" :sm="6" :lg="3">
                    <el-button type="success" @click="updateUpPoint" :disabled="upPointFormBlocking">上分</el-button>
{#                    <el-button type="success" @click="upPointFormVisible = true">上分</el-button>#}
                </el-col>
                <el-col :xs="8" :sm="4" :lg="3">
                    <el-input v-model="downPoint" style="font-size: 18px;"></el-input>
                </el-col>
                <el-col :xs="12" :sm="6" :lg="4">
                    <el-button type="danger" @click="updateDownPoint" :disabled="downPointFormBlocking">下分</el-button>
{#                    <el-button type="danger" @click="downPointFormVisible = true">下分</el-button>#}
                </el-col>
            </el-row>
        </el-card>
    </el-row>
    {% endif %}
    <el-row>
        <el-table :data="gamesets" @sort-change="onSortChanged" @row-click="onTableRowClick">
            <el-table-column prop="sn" label="期号">
            </el-table-column>
            <el-table-column prop="wagerAmount" label="下注积分">
            </el-table-column>
            <el-table-column prop="envelopeAmount" label="红包金额">
            </el-table-column>
            <el-table-column prop="grabPoint" label="红包点数">
            </el-table-column>
            <el-table-column prop="earnedAmount" label="盈亏">
            </el-table-column>
        </el-table>
    </el-row>
    <el-row>
        <el-pagination background layout="prev, pager, next" :total="gamesetsCount" page-size=30 :current-page.sync="currentPage" @current-change="onCurrentPageChanged">
        </el-pagination>
    </el-row>
{#    {% if current_user.is_admin %}#}
{#    <el-dialog :visible.sync="upPointFormVisible" title="上分">#}
{#        <el-form v-loading="upPointFormBlocking" element-loading-text="提交修改 &hellip;" element-loading-spinner="el-icon-loading">#}
{#            <el-form-item label="上分">#}
{#                <el-input v-model="upPoint" autofocus="true">#}
{#                    <!--<template slot="prepend">https://www.instagram.com/</template>-->#}
{#                </el-input>#}
{#            </el-form-item>#}
{#            <el-form-item>#}
{#                <el-button type="primary" @click="updateUpPoint">修改</el-button>#}
{#                <el-button @click="upPointFormVisible = false" class='el-dialog__close'>取消</el-button>#}
{#            </el-form-item>#}
{#        </el-form>#}
{#    </el-dialog>#}
{#    <el-dialog :visible.sync="downPointFormVisible" title="下分">#}
{#        <el-form v-loading="downPointFormBlocking" element-loading-text="提交修改 &hellip;" element-loading-spinner="el-icon-loading">#}
{#            <el-form-item label="下分">#}
{#                <el-input v-model="downPoint">#}
{#                    <!--<template slot="prepend">https://www.instagram.com/</template>-->#}
{#                </el-input>#}
{#            </el-form-item>#}
{#            <el-form-item>#}
{#                <el-button type="primary" @click="updateDownPoint">修改</el-button>#}
{#                <el-button @click="downPointFormVisible = false" class='el-dialog__close'>取消</el-button>#}
{#            </el-form-item>#}
{#        </el-form>#}
{#    </el-dialog>#}
{#    {% endif %}#}
</div>
{% endblock content %} {% block js %}
<script>
var container = new Vue({
    el: "#content",
    data: function() {
        return {
            playerWxid: "{{ player_wxid }}",
            player: {},
            currentPage: 1,
            gamesetsCount: 0,
            gamesets: [],
            upPointFormVisible: false,
            downPointFormVisible: false,
            upPointFormBlocking: false,
            downPointFormBlocking: false,
            upPoint: '',
            downPoint: ''
        }
    },
    methods: {
        onSortChanged: function(args) {
            console.log(args);
        },
        onTableRowClick: function(row, event, column) {
            console.log(row);
            console.log(column);
            console.log(column);
        },
        updateUpPoint: function() {
            if (this.upPoint === '') {
                return;
            }
            this.upPointFormBlocking = true;
            this.$http.put('/api/player/' + this.playerWxid, {
                upPoint: this.upPoint
            }).then((res) => {
                this.$notify({
                    title: "上分成功",
                    message: "上分成功",
                    type: "success"
                });
                setTimeout(() => location.reload(), 500);
            }).catch((err) => {
                console.log(err.response.data);
                this.$notify.error({
                    title: "上分失败",
                    message: err.response.data.message
                });
                this.upPointFormBlocking = false;
            });
        },
        updateDownPoint: function() {
            if (this.downPoint === '') {
                return;
            }
            this.downPointFormBlocking = true;
            this.$http.put('/api/player/' + this.playerWxid, {
                downPoint: this.downPoint
            }).then((res) => {
                this.$notify({
                    title: "下分成功",
                    message: "下分成功",
                    type: "success"
                });
                setTimeout(() => location.reload(), 500);
            }).catch((err) => {
                this.$notify.error({
                    title: "下分失败",
                    message: err.response.data.message
                });
                this.downPointFormBlocking = false;
            });
        },
        onCurrentPageChanged: function(currentPage) {
            this.refreshGamesetDetail();
        },
        refreshGamesetDetail: function() {
            this.$http.get('/api/player/' + this.playerWxid, {
                params: {
                    page: this.currentPage - 1,
                }
            }).then((res) => {
                this.player = res.data.player;
                this.gamesetsCount = res.data.count;
                this.gamesets = res.data.gamesets;
            });
        },
    },
    created: function() {
        this.refreshGamesetDetail();
    }
});
</script>
{% endblock js %}